//
//  GameLayer.h
//  Birds
//
//  Created by Denveryee on 14-2-10.
//
//

#ifndef __Birds__GameLayer__
#define __Birds__GameLayer__

#include "cocos2d.h"

USING_NS_CC;

class GameLayer : public cocos2d::CCLayer
{
public:
    CCSize size;
    CCSprite* sprPipe1;
    CCSprite* sprPipe2;
    
    cocos2d::CCArray *_birds;
    
    bool pipeClose;
    //游戏得分；
    int score;
    CCLabelAtlas* labelScore;

    CCSprite *blood;
    CCSpriteFrame *frame0;
    CCArray* animFrames;
    
    bool gameOverCheck;
    CCLayer* endBgLayer;
    CCMenuItem *itemShare;
    
    bool cheer1;
    bool cheer2;
    bool cheer3;
    
    bool newRecord;
public:
    GameLayer(void);
	~GameLayer(void);
    
    virtual bool init();
    
    CREATE_FUNC(GameLayer);
    
    // a selector callback
    void menuCloseCallback(CCObject* pSender);
    
    //重写触屏回调函数
    virtual bool ccTouchBegan(cocos2d::CCTouch* touch, cocos2d::CCEvent* event);
    virtual void ccTouchMoved(cocos2d::CCTouch* touch, cocos2d::CCEvent* event);
    virtual void ccTouchEnded(cocos2d::CCTouch* touch, cocos2d::CCEvent* event);
    
    //重写生命周期函数
    virtual void onEnter();
    virtual void onExit();
    
    virtual void update(float dt);
    
    void pipeCloseCallback();
    virtual void createBird(float dt);
    virtual void createCloud(float dt);
    
    void removeBird(CCNode* pSender, void* data);
    
    void menuEPlayCallback();
    void menuEShareCallback();
    
    void gameOverAction(CCNode* pSender);
    void starOverAction(CCNode* pSender);
    void shareAction(CCNode* pSender);
    
    void pipeCloseSound();
    void gameOver();
    void buttonM();
};
#endif /* defined(__Birds__GameLayer__) */
